package com.qinggeng.framework.config.mq.impl;

import com.alibaba.fastjson.JSONObject;
import com.qinggeng.framework.config.mq.dto.MessageLuckyDrawDTO;
import com.qinggeng.framework.config.mq.handle.MessageHandle;
import com.qinggeng.project.api.websocket.service.BulletChatLuckyDrawServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 吴鹏飞
 * @date 2020/12/5
 * 中奖推送
 */
@Component
@Slf4j
public class  BulletChatLuckyDrawHandImpl implements MessageHandle {
    @Resource
    private BulletChatLuckyDrawServiceImpl luckyDrawService;

    @Override
    public void handle(String msg) {
        log.info("--------中奖推送开始----------");
        try {
            MessageLuckyDrawDTO messageLuckyDrawDTO = JSONObject.parseObject(msg, MessageLuckyDrawDTO.class);
            luckyDrawService.send(messageLuckyDrawDTO);
        } catch (Exception e) {
            log.info("LuckyDrawHandImpl.handle()={}",e.getMessage());
        }
        log.info("--------中奖推送结束----------");
    }
}
